package com.ocean.controller.edu;

import com.ocean.entity.edu.Student;
import com.ocean.service.edu.StudentService;
import com.ocean.vo.R;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;

/**
 * @author greenbird
 * @create 2023-03-04 15:41
 */
@RestController
@RequestMapping("/api/edu/student/")
public class StudentController {
    @Autowired
    private StudentService service;

    @PostMapping("save.do")
    public R save(@RequestBody Student student){
        return service.save(student);
    }
    @PostMapping("update.do")
    public R update(@RequestBody Student student){
        return service.update(student);
    }
    @GetMapping("del.do")
    public R delete(int id){
        return service.delete(id);
    }
    @GetMapping("page.do")
    public R page(String sname,String sex,String classid,int page,int size){
        return service.queryPage(sname,sex,classid,page,size);
    }

    @GetMapping("selectStuBySid.do")
    public Student selectStuBySid(Integer sid){
        return service.queryById(sid);
    }

    @PostMapping("import.do")
    public R importData(MultipartFile file){
        return service.importData(file);
    }
    @GetMapping("export.do")
    public void exportData(HttpServletResponse response){
        service.exportData(response);
    }

    @GetMapping("selectIdByName.do")
    public R selectIdByName(String name){
        return service.selectIdByName(name);
    }
}

